define(function(require,exports,module) {
    var myPub = require('./public');
    var lazLoading = new myPub.lazLoadingImg();
    var oGoodsList = $('.js_goodsList');        // 商品列表
    var oGoodsArea = $('.js_goodsArea');
    var oContain = $('.js_contain');
    var goodsListUrl = '/m/g/1.0/group/listGoodsByName';
    var oJumpA = $('.jumpHref a');
    var oGoodsNonePage = $('.js_goodsNonePage');
    var oLoadNull = $('.js_loadNull');
    myPub.JudgeAppHref(oJumpA);

    var goodsArea = {

        // 获取数据
        getData:function(fn){
            var _this = this;
             G_JSON_GET(goodsListUrl,{ start: 0, limit: 20, groupName: 'H5_猜你喜欢'},function (data) {
                 var dataItem = data.data;
                 if(dataItem && dataItem.length > 0){
                     oGoodsNonePage.show();
                     oLoadNull.show();
                     oGoodsList.append(_this.guessGoodsHtml(dataItem));
                 }
                 myPub.JudgeAppHref(oGoodsList.find('a'));
                 lazLoading.DestroyLazLoadingImg();
                 lazLoading.AddLazLoadingImg(oContain[0]);
             })
        },

        //商品列表
        guessGoodsHtml: function (data) {
            var shtml = '';

            for(var i = 0; i < data.length; i++){
                var item = data[i];
                var quanpeiHtml = '';
               /*var goodsLabel = '';
                var goodsHref = '';
                var priceHtml = '';
                if(item.tuangou){
                    goodsHref = BASE_URL+'/GroupBuying/goods/'+item.goodsSn;
                    priceHtml = item.tuangouPrices;
                }else{
                    goodsHref =BASE_URL+'/h/goodspay/goodsView/'+item.goodsSn;
                    // goodsHref = BASE_URL+'/h/goodspay/goodsView/'+item.goodsSn;
                    priceHtml = item.salePrice;
                }*/
                //如果有全赔图标则显示
                if(item.firstGueeImagePath) {
                    quanpeiHtml = '<div class="quanpei"><img src="https://img.sfddj.com/miniappImg/public/goodsInfo/'+item.firstGueeImagePath+'" alt="" /></div>'
                }

                shtml += '<li>' +
                    '          <a class="BoxSelf" _href="'+item.goodsSn+'" requestid="'+item.requestId+'"  goodsid="'+ item.goodsId +'">' +
                    '                <figure>' +
                    '                     <img class="js_lazyImg" data-echo="'+HTTP_IMAGE_URL + item.goodsDefaultImage + smallImgArg200+'" src="'+ BASE_URL +'/static_v4/image/loadImg.jpg">' +
                    quanpeiHtml +
                    '                 </figure>' +
                    '                 <aside class="priceArea VBox Bflex1">' +
                    '                      <div class="Bflex1 priceArea_name">' +
                    '                           <h4>'+item.goodsName+'</h4>' +
                    '                           <p class="smallFont_tip">'+ item.goodsTitle +'</p>' +
                    '                       </div>' +
                    '                       <div class="priceArea_price">' +
                    '                            <p class="HBox priceAreaBox">' +
                    '                                 <span class="goodsPrice">￥'+ item.salePrice +'</span>' +
                    '                             </p>' +
                    '                         </div>' +
                    '                   </aside>' +
                    '            </a>' +
                    '            <p class="addCar js_addCar" pid="'+ item.productId +'"><em class="icon-shopcar_small"></em></p>' +
                    '       </li>';

            }

            return shtml;
        }
    };

    lazLoading.AddLazLoadingImg(oGoodsList[0]);
    goodsArea.getData();
});